<?php

/**
 * Produit filter form base class.
 *
 * @package    frigospeed
 * @subpackage filter
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 29570 2010-05-21 14:49:47Z Kris.Wallsmith $
 */
abstract class BaseProduitFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'description'     => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'type'            => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'volume'          => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'dimension'       => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'conservationmax' => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'conservationmin' => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'date'            => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
      'photo'           => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'idutilisateur'   => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Utilisateur'), 'add_empty' => true)),
      'identrepot'      => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Entrepot'), 'add_empty' => true)),
    ));

    $this->setValidators(array(
      'description'     => new sfValidatorPass(array('required' => false)),
      'type'            => new sfValidatorPass(array('required' => false)),
      'volume'          => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
      'dimension'       => new sfValidatorPass(array('required' => false)),
      'conservationmax' => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'conservationmin' => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'date'            => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDateTime(array('required' => false)))),
      'photo'           => new sfValidatorPass(array('required' => false)),
      'idutilisateur'   => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Utilisateur'), 'column' => 'idutilisateur')),
      'identrepot'      => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Entrepot'), 'column' => 'identrepot')),
    ));

    $this->widgetSchema->setNameFormat('produit_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Produit';
  }

  public function getFields()
  {
    return array(
      'idproduit'       => 'Number',
      'description'     => 'Text',
      'type'            => 'Text',
      'volume'          => 'Number',
      'dimension'       => 'Text',
      'conservationmax' => 'Number',
      'conservationmin' => 'Number',
      'date'            => 'Date',
      'photo'           => 'Text',
      'idutilisateur'   => 'ForeignKey',
      'identrepot'      => 'ForeignKey',
    );
  }
}
